﻿#include "globalvars.h"
#include <QBitmap>
#include <QPainter>

ConfigOperate GlobalVars::g_localConfig;

int GlobalVars::count = 0;///酒店符合条件的记录个数
SaveInfo GlobalVars::g_localSave;
UserInfo GlobalVars::g_localUser;
HotelInfo GlobalVars::g_localHotel;
HouseInfo GlobalVars::g_localHouse;
ReserveInfo GlobalVars::g_localReserve;
CommentInfo GlobalVars::g_localComment;
ImageList GlobalVars::g_hotelImageList;
ImageList GlobalVars::g_houseImageList;

UserInfoList* GlobalVars::g_userInfoList = new UserInfoList();
ReserveInfoList* GlobalVars::g_reserveInfoList = new ReserveInfoList();
CommentInfoList* GlobalVars::g_commentInfoList = new CommentInfoList();
HotelInfoList* GlobalVars::g_hotelManageList = new HotelInfoList();
HotelInfoMap GlobalVars::g_hotelManageMap;
QMap<QString,QString> GlobalVars::g_serverStyleSheet;

ImageListMap GlobalVars::g_commentImageListMap;
QQueue<QString> GlobalVars::g_msgQueue;
QQueue<ImageMsgMap> GlobalVars::g_ImageMsgQueue;
QVector<QString> GlobalVars::week(7,"");

GlobalVars::GlobalVars()
{

}

void GlobalVars::setWeek(QVector<QString> weekVec)
{
    week = weekVec;
}

void GlobalVars::setWeek(QStringList weekList)
{
    for (int i = 0; i < weekList.size(); i++)
    {
        week[i] = weekList.at(i);
    }
}

void GlobalVars::setHotelServerStyleSheetMap()
{
    g_serverStyleSheet.insert("免费停车", "border-image: url(:/images/littleIcon/park.png);");
    g_serverStyleSheet.insert("收费停车", "border-image: url(:/images/littleIcon/park.png);");
    g_serverStyleSheet.insert("接送服务", "border-image: url(:/images/littleIcon/transfer.png);");
    g_serverStyleSheet.insert("热水洗浴", "border-image: url(:/images/littleIcon/bath.png);");
    g_serverStyleSheet.insert("电吹风", "border-image: url(:/images/littleIcon/electricHairDrier.png);");

    g_serverStyleSheet.insert("温泉", "border-image: url(:/images/littleIcon/hotSpring.png);");
    g_serverStyleSheet.insert("有线上网", "border-image: url(:/images/littleIcon/network.png);");
    g_serverStyleSheet.insert("无线上网", "border-image: url(:/images/littleIcon/wifi.png);");
    g_serverStyleSheet.insert("行李寄存", "border-image: url(:/images/littleIcon/baggage.png);");
    g_serverStyleSheet.insert("餐厅", "border-image: url(:/images/littleIcon/diningHall.png);");
}

QPixmap GlobalVars::PixmapToRound(const QPixmap &src, int radius)
{
    if (src.isNull()) {
        return QPixmap();
    }
    QSize size(2*radius, 2*radius);
    QBitmap mask(size);
    QPainter painter(&mask);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setRenderHint(QPainter::SmoothPixmapTransform);
    painter.fillRect(0, 0, size.width(), size.height(), Qt::white);
    painter.setBrush(QColor(0, 0, 0));
    painter.drawRoundedRect(0, 0, size.width(), size.height(), 99, 99);
    QPixmap image = src.scaled(size);
    image.setMask(mask);
    return image;
}

